package com.doit.day02

import scala.collection.immutable
import scala.io.Source

/**
*1,4
*2,5
*4,6
*2,4
*3,6
*4,6
*1,5
 */
object _05_线段重叠 {
  def main(args: Array[String]): Unit = {

    val line = Source.fromFile("D:\\develop\\ideaWorkSpace\\myself\\Teach\\scalaDemo\\data\\line").getLines().toList

    val inclusives: immutable.Seq[Range] = line.map(line => {
      val arr: Array[String] = line.split(",")
      val start: Int = arr(0).toInt
      val end: Int = arr(1).toInt
      val seq = start.until(end)
      seq
    })

    val flatten: immutable.Seq[Int] = inclusives.flatten

    val map: Map[Int, immutable.Seq[Int]] = flatten.groupBy(point => point)

    map.map(map=>(map._1,map._2.size)).foreach(println)
  }
}
